package com.management.department.teacherinfosystem.Repository;

import com.management.department.teacherinfosystem.Entity.PartyActivity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Date;
import java.util.List;

public interface PartyActivityRepository extends JpaRepository<PartyActivity, Long>, JpaSpecificationExecutor<PartyActivity> {
	@Query("select p from PartyActivity p where (:type is null or p.activityType = :type) and (:start is null or p.activityDate >= :start) and (:end is null or p.activityDate <= :end) order by p.activityDate desc, p.createdAt desc")
	List<PartyActivity> search(@Param("type") String type, @Param("start") Date start, @Param("end") Date end);

	List<PartyActivity> findByStatus(@Param("status") String status);
} 